-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better python package identification #215
Better python package identification #215
Conversation
09eb1d8
to
e17f0ff
Compare
Codecov Report
@@ Coverage Diff @@
## master #215 +/- ##
==========================================
- Coverage 80.24% 80.23% -0.01%
==========================================
Files 54 55 +1
Lines 3098 3097 -1
Branches 512 511 -1
==========================================
- Hits 2486 2485 -1
Misses 576 576
Partials 36 36
Continue to review full report at Codecov.
|
@dirk-thomas, Finally got it to pass CI! This was a bear - for some reason colcon doesn't seem to work properly when installed in editable (developer) mode. Shall I squash before or after you take a first review pass? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason colcon doesn't seem to work properly when installed in editable (developer) mode.
I would be very surprised if that is the case. A symlink install / develop mode is my primary work environment and it works just fine for me. Please feel free to create a separate ticket with specifics if there is something which needs fixing.
Shall I squash before or after you take a first review pass?
No need to. I will take a look at it right away...
Please don't change the line limit and revert 0c94427. |
so not this? https://index.ros.org//doc/ros2/Contributing/Developer-Guide/#id4 |
Yeah, |
71433fd
to
d3ca897
Compare
It successfully builds the entire ROS2 source tree now! |
Both of these arguments are limitations in tooling. Those should go away when we move f-strings (see next comment).
That is exactly the intention. Once we can drop Python 3.5 support all |
Sorry for the numerous small edits. I thought I could address a few nitpicks through the GitHub UI but then it went down a rabit hole. I should have edited the files locally and pushed the changes to this branch instead... For the moment I have stopped iterating on the patch since I am unable to bootstrap the
The problem seems to be due to the switch to the That being said maybe it would be better to:
What do you think? |
It's all good. I basically live down a fractal rabbit hole.
I'll take a look. That particular issue looks as simple as adding 'cmdclass' to the blacklist here https://github.com/RoverRobotics-forks/colcon-core/blob/fbaa13384f97740b968bdeaf975f751dab298a29/colcon_core/package_identification/python.py#L154-L162 It's possible to just not use multiprocessing and run setup.py in the colcon process, but I figured isolating package setup.py's from each other is a desirable feature. I do like this approach (I'm sure in part because I've sunk so much time and effort into it) and I think it's going to do the right thing more often than either the setup.py or setup.cfg approach. I'd like to fix it and ship it 🚀 |
That sounds like a viable option to me.
I wasn't suggesting that. Even the |
d9f7c39
to
53915a2
Compare
Please rebase your branch on top of the latest state of |
53915a2
to
63ba56b
Compare
Rebased. |
While the CI tests pass one of the tests fails when running |
6a43078
to
d300e75
Compare
Why is the change in 1cf7b4f necessary? Could this be deferred to a separate PR instead to keep the diff minimal? |
94a420b
to
23f0605
Compare
This is waiting for #229, right? |
Yes. |
59bf510
to
92af5f1
Compare
While #229 should land first it would be good to see this PR pass CI and then show the coverage impact of both PRs (since this one includes the other one). Let me know once that is the case so I can re-review. Thanks. |
Previously, we either monkey-patched setuptools and harvested the arguments passed to setuptools.setup or we parsed setup.cfg Now we run the setup.py script with distutils.core.run_setup to return properties from the resulting Distribution object.
92af5f1
to
1864386
Compare
Done. In retrospect, splitting this up into two PRs has seemed to be a mistake :-( |
Overall what this patch does looks good to me. The only thing making me a bit worry is the introduced complexity into I brought up the alternative above and would still be interested what you think about moving the functionality in
|
I don't like the idea of having two implementations of the same logical operation, but you gave me an idea... |
65bfdeb
to
b9fd456
Compare
|
971d916
to
192fcda
Compare
It turns out most of what I was doing with multiprocessing.Process was reinventing Pool.apply. This also naturally throttles the number of simultaneous processes, which was a possible concern. Move setup.py-specific stuff to run_setup_py. I expect to reuse this for python build, plus isolating it makes the subprocess workload minimal.
192fcda
to
3f670a8
Compare
@dirk-thomas, I think you're gonna like this. I switched to a process pool to reduce the number of simultaneous processes (by default = number of CPU cores) and the code is even cleaner. Still passes all the tests :-). |
Oh and setuptools read_configuration is not even threadsafe on simple cfg files. It uses os.chdir. |
@dirk-thomas So now that it uses a process pool, this will not create arbitrarily many parallel processes which averts the Windows issue you mentioned. As for the complexity, I’d rather have one, more complex and correct code path than two partial ones. Bugs hide in poorly-exercised code paths. If you'd rather move python discovery and building out of this package entirely, that sounds like a great task for a follow-on PR. Is there something I’m missing or can this move forward as-is? |
I thought about this for a while and my main goal is to keep the complexity in Certainly the former needed fixing to not handle cases it didn't actually support (see colcon/colcon-ros#65).
Python package identification can't be moved out of the core since this package wouldn't be able to bootstrap itself anymore (see https://colcon.readthedocs.io/en/released/developer/bootstrap.html). Can you take a look at colcon/colcon-python-setup-py#22 and see if that works for your use case, too. |
Closing in favor of colcon/colcon-python-setup-py#22. |
Supersedes colcon/colcon-python-setup-py#21